package org.example.work2.at.order.controller;


import lombok.extern.slf4j.Slf4j;
import org.example.work2.at.order.dto.Order;
import org.example.work2.at.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author xh
 * @date 2023/04/03
 */
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {


    @Autowired
    private OrderService orderService;

    @PostMapping("/create")
    public boolean createOrder(@RequestBody Order order) throws Exception {
        log.info("[createOrder] 收到下单请求, 用户:{}, 商品:{}, 数量:{}", order.getAccountCode(), order.getProductName(), order.getProductCounts());
        return orderService.createOrder(order);
    }

}
